#include <QGuiApplication>
#include <QtQml>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include "serialportpro.h"
#include "fileio.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    system("cp ../TL_Q/*.qml ./ -f");
    system("cp ../TL_Q/*.js ./ -f");
    //system("cp ../TL_Q/*.xml ./ -f");
    //system("cp ../TL_Q/*.json ./ -f");
    qmlRegisterType<FileIO, 1>("FileIO", 1, 0, "FileIO");
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("main.qml")));
    QQuickWindow *window = qobject_cast<QQuickWindow *>(engine.rootObjects().first());
    window->showFullScreen();

    Serialportpro *my  = new Serialportpro();
    QObject::connect((QObject*)window, SIGNAL(sendpresskey(int)), my, SLOT(pushCommand(int)));
    QObject::connect(my,SIGNAL(state_s(QVariant)),(QObject*)window,SLOT(state_c(QVariant)));
    QObject::connect(my,SIGNAL(flr_s(QVariant)),(QObject*)window,SLOT(flr_c(QVariant)));
    QObject::connect(my,SIGNAL(dir_s(QVariant)),(QObject*)window,SLOT(dir_c(QVariant)));
    QObject::connect(my,SIGNAL(regflr_s(QVariant)),(QObject*)window,SLOT(regflr_c(QVariant)));
    QObject::connect(my,SIGNAL(unregflr_s(QVariant)),(QObject*)window,SLOT(unregflr_c(QVariant)));
    QObject::connect(my,SIGNAL(voice_s(QVariant)),(QObject*)window,SLOT(voice_c(QVariant)));
    QObject::connect(my,SIGNAL(vision_s(QVariant)),(QObject*)window,SLOT(vision_c(QVariant)));

    QObject::connect(my,SIGNAL(light_s(QVariant)),(QObject*)window,SLOT(light_c(QVariant)));
    QObject::connect(my,SIGNAL(fan_s(QVariant)),(QObject*)window,SLOT(fan_c(QVariant)));
    QObject::connect(my,SIGNAL(jl_s(QVariant)),(QObject*)window,SLOT(jl_c(QVariant)));
    return app.exec();
}
